package com.dyh.quickdemo.binjouSpring;

import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import java.io.*;

/*
@Author=Joey Wheeler
@Date=2021/4/26 16:24
*/
public class BinJouSpring {

    @Test
    public void test() throws IOException {
//        ClassPathResource classPathResource = new ClassPathResource("spring-context.xml");

        //BinJouSpring

     //   String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
       // File file = new File(" com.dyh.quickdemo.binjouSpring");

//        ClassLoader loader = BinJouSpring.class.getClassLoader();
        ClassLoader loader = this.getClass().getClassLoader();
//        InputStream inputStream = loader.getResourceAsStream("com//dyh//quickdemo//binjouSpring.BinJouSpring.java");

        InputStream inputStream = loader.getResourceAsStream("com//dyh//quickdemo//binjouSpring//a.txt");
      //  InputStream inputStream = new FileInputStream(file);
        BufferedReader rd = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        StringBuilder stringBuilder = new StringBuilder();
        while ((line = rd.readLine()) != null)
            stringBuilder.append(line);

//        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));

        System.out.println(stringBuilder.toString());


        System.out.println();

    }
}
